<template>
  <right-template :title="componentData.title" :tabName="componentData.tabName">
    <el-form class="right-img">
      <dropdown-normal label="绑定动态字段" :valLists="COMPONENT_IMG_DATAKEYS" v-model="commonAttr.dataKey" @change="onChangeAttr"></dropdown-normal>
      <add-img-con :url="commonAttr.url" comAttr="commonAttr" picAttr="url" :isCrop="true" :isDelete="true" class="margin-left-right-16"></add-img-con>
      <input-normal label="图片地址" v-model="commonAttr.url" @change="onChangeAttr"></input-normal>
      <input-normal label="图片描述" v-model="commonAttr.name" @change="onChangeAttr"></input-normal>
      <el-divider content-position="center">高级属性</el-divider>
      <switch-normal v-model="commonAttr.isDynamic" label="动态图片" @change="onChangeAttr"></switch-normal>
      <switch-normal v-model="commonAttr.isSaveImg" :label="'是否可以保存图片'" @change="onChangeAttr"></switch-normal>
      <switch-normal v-model="commonAttr.isForm" :label="'交互（表单提交）'" @change="onChangeAttr"></switch-normal>
      <template v-if="commonAttr.isForm">
        <input-normal label="导出表头" v-model="commonAttr.tableName" @change="onChangeAttr"></input-normal>
        <switch-normal v-model="commonAttr.need" :label="'设为必填项'" @change="onChangeAttr"></switch-normal>
      </template>
      <switch-normal v-model="commonAttr.isFullScreen" label="全屏" @change="onChangeAttr"></switch-normal>
      <dropdown-normal v-if="commonAttr.isFullScreen" label="图片填充样式" :valLists="IMG_FILL_TYPE" v-model="commonAttr.objectFit" @change="onChangeAttr"></dropdown-normal>
      <input-normal label="内距" placeholder="上 右 下 左" v-model="commonAttr.padding" @change="onChangeAttr"></input-normal>
      <color-normal v-model="commonAttr.backgroundColor" label="背景颜色" format="rgb" @change="onChangeAttr"></color-normal>
    </el-form>
  </right-template>
</template>

<script setup lang="ts">
import { useWebComponentStore } from '@/store/web/component'
import { COMPONENT_IMG_DATAKEYS } from '@/const/web/'
import { IMG_FILL_TYPE } from '@/const/'

const useWebComponent = useWebComponentStore()

let componentData_: any
const componentData = computed(() => {
  componentData_ = useWebComponent.currentComponentData
  return componentData_
})
let commonAttr_: any
const commonAttr = computed(() => {
  commonAttr_ = useWebComponent.currentComponentData!.commonAttr
  return commonAttr_
})
const onChangeAttr = () => {
  // useWebComponent.updateCurrentComponentData({ commonAttr: commonAttr_ })
}
</script>
